function Initialize-SqlProvider
{
    # $sqlpsreg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps"
    #
    #if (Get-ChildItem $sqlpsreg -ErrorAction "SilentlyContinue")
    #{
    #    throw "SQL Server Powershell Provider is not installed."
    #}
    #else
    #{
    #    $item = Get-ItemProperty $sqlpsreg
    #    $sqlpsPath = [System.IO.Path]::GetDirectoryName($item.Path)
    #}

    # registry path can't be read from 32-bit Powershell; hardcode for now
    $sqlpsPath = join-path ${env:ProgramFiles(x86)} "Microsoft SQL Server\100\Tools\Binn"

    #
    # Set mandatory variables for the SQL Server PowerShell provider
    #
    Set-Variable -scope Global -name SqlServerMaximumChildItems -Value 0
    Set-Variable -scope Global -name SqlServerConnectionTimeout -Value 30
    Set-Variable -scope Global -name SqlServerIncludeSystemObjects -Value $false
    Set-Variable -scope Global -name SqlServerMaximumTabCompletion -Value 1000

    #
    # Load the snapins, type data, format data
    #
    Push-Location $sqlpsPath
    Add-PSSnapin SqlServerCmdletSnapin100
    Add-PSSnapin SqlServerProviderSnapin100
    Update-TypeData -PrependPath SQLProvider.Types.ps1xml 
    Update-FormatData -prependpath SQLProvider.Format.ps1xml 
    Pop-Location
}